home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 748 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. From: jdmorris@ix.netcom.com (Jason D. Morris)
  2. Message-ID: <314b1f7b.6864220@nntp.ix.netcom.com>
  3. X-Original-Date: Sat, 16 Mar 1996 20:09:40 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 17 Mar 96 03:57:19 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Exception handling -- was a finally block ever considered?
  9. Organization: Netcom
  10. References: <31475017.8100207@nntp.ix.netcom.com> <ERIC.96Mar15153848@cse.unl.edu>
  11. X-Netcom-Date: Sat Mar 16 12:08:53 PM PST 1996
  12. X-Newsreader: Forte Agent .99d/32.182
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMUuNq+EDnX0m9pzZAQG1LQGAi5BRMpvQNYbUe1u4Qx/LfRrgE5ut507g
  15.     2mKazLCXOC0Rhh3rjbGR/8oas0gv9Y1a
  16.     =7MTH
  17.  
  18. On 16 Mar 96 10:13:46 GMT, ebiederm@cse.unl.edu (Eric W. Biederman)
  19. wrote:
  20. >This can be written quite easily as I see it with C++, though the
  21. >structure is a little awkward. 
  22. >
  23. >Basically you just need to write a destructor.  The code ordering is a
  24. >little less pleasant 
  25. >Say,
  26. >
  27. >func( ... )
  28. >{
  29. >   class finally{
  30. >   public:
  31. >   ~finally()
  32. >   {
  33. >       // code that would be guaranteed to execute no matter how the 
  34. >       // function was exited.
  35. >   } finally;
  36. >   try
  37. >   {
  38. >       // some code that could generate an exception...
  39. >   }
  40. >   catch ( // some expected exception type )
  41. >   {
  42. >       // handler code
  43. >   }
  44. >}
  45.  
  46. Ok, but that still doesn't answer my question.  I didn't ask for a
  47. method for simulating a finally block, I asked if the committee had
  48. considered a finally block as part of the exception handling
  49. mechanism, and if they had, why it wasn't adopted.
  50.  
  51. Jason
  52. ---
  53. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  54. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  55. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  56. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  57. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  58.